package socketHandler;
/**
 * 
 * @author Peter Steiner & Fredrik Wallenius
 *
 */
import java.net.*;
import java.util.Scanner;
import java.io.*;

public class TCPClient {
	
	public static final int SERVER_PORT = 3491;
	private Socket sock;
	
	public TCPClient(String[] args) throws IOException {

		if(args.length != 1) {
			System.out.println("Usage: tcp_client hostname");
			System.exit(0);
		}
		
		sock = null;
		
		try {
			// Connect to server
			InetAddress serverAddr = InetAddress.getByName(args[0]);
			sock = new Socket(serverAddr, SERVER_PORT);
		}
		// Close socket...
		finally {
			try {
				if(sock == null)
				System.out.println("[Client]: Couldn't bind socket..");
				else
				System.out.println("[Client]: Socket running..");
			}catch(Exception e) {}
		}
	}
	public Socket getSocket(){
		return sock;
	}
}